<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2023/12/25
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <style>
        .footer {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        input {
            width: 50%;
        }
    </style>
</head>
<body>
<div class="skin-default" id="wrapper">
    <%@include file="/static/pages/head/header.jsp" %>
    <div class="page-wrapper">
        <div class="page-header">
            <h1 class="title">
                入库管理
                <small>入库信息表</small>
            </h1>
        </div>
        <section class="page-body">
            <div class="row widget">
                <section class="col-md-12">
                    <div class="box table">
                        <div class="box-body">
                                <form class="form-horizontal" method="post" action="${pageContext.request.contextPath}/instore/">

                                    <div class="form-group">
                                        <label  class="col-sm-2 control-label">入库产废</label>
                                        <select name="deptId" class="form-control" style="width: 300px" id="productselect">
                                            <c:forEach items="${productlist}" var="product">
                                                <option value="${product.productId}">${product.productCode}</option>
                                            </c:forEach>
                                        </select>
                                    </div>

                                   <input type="hidden" name="wasteId"/>
                                    <div class="form-group">
                                        <label for="waste_code" class="col-sm-2 control-label">废物编码</label>
                                        <div class="col-sm-10">
                                            <input text="waste_code" name="wasteCode" class="form-control" style="width: 300px" id="waste_code" placeholder="waste_code" readonly />
                                        </div>
                                    </div>


                                    <input type="hidden" name="productId"/>
                                    <div class="form-group">
                                        <label for="product_code" class="col-sm-2 control-label">产废编码</label>
                                        <div class="col-sm-10">
                                            <input text="product_code" name="productCode" class="form-control" style="width: 300px" id="product_code" placeholder="product_code" readonly />
                                        </div>
                                    </div>


                                    <input type="hidden" name="containerId"/>
                                    <div class="form-group">
                                        <label for="container_code" class="col-sm-2 control-label">容器编码</label>
                                        <div class="col-sm-10">
                                            <input text="container_code" name="containerCode" class="form-control" style="width: 300px" id="container_code" placeholder="container_code" readonly>
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label for="waste_source" class="col-sm-2 control-label">行业来源</label>
                                        <div class="col-sm-10">
                                            <input text="waste_source" name="wasteSource" class="form-control" style="width: 300px" id="waste_source" placeholder="waste_source" readonly />
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label for="waste_commonName" class="col-sm-2 control-label">行业俗称</label>
                                        <div class="col-sm-10">
                                            <input text="waste_commonName" name="wasteCommonname" class="form-control" style="width: 300px" id="waste_commonName" placeholder="waste_commonName" readonly>
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label for="waste_hazardous" class="col-sm-2 control-label">危险废物</label>
                                        <div class="col-sm-10">
                                            <input text="waste_hazardous" name="wasteHazardous" class="form-control" style="width: 300px" id="waste_hazardous" placeholder="waste_hazardous" readonly />
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label for="type_name" class="col-sm-2 control-label">废物类别名称</label>
                                        <div class="col-sm-10">
                                            <input text="type_name" name="typeName" class="form-control" style="width: 300px" id="type_name" placeholder="type_name" readonly />
                                        </div>
                                    </div>


                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" id="instore">确定</button>
                                    </div>
                                </form>
                        </div>
                    </div>
                </section>
            </div>
        </section>
    </div>
</body>
</html>
<script>
    $("#productselect").change(function (){
        var val = $(this).find('option:selected').val();
        $.ajax({
            type: "GET",
            url: "${pageContext.request.contextPath}/instore/getproduct/" + val,
            success: function (product) {
                $("[name='wasteId']").val(product.wasteId);
                $("[name='wasteCode']").val(product.wasteCode);
                $("[name='productId']").val(product.productId);
                $("[name='productCode']").val(product.productCode);
                $("[name='containerId']").val(product.containerId);
                $("[name='containerCode']").val(product.containerCode);
                $("[name='wasteSource']").val(product.wasteSource);
                $("[name='wasteCommonname']").val(product.wasteCommonname);
                $("[name='wasteHazardous']").val(product.wasteHazardous);
                $("[name='typeName']").val(product.typeName);
            }
        })
    })
    $("#instore").click(function (){
        var wasteId = $("[name='wasteId']").val();
        var wasteCode = $("[name='wasteCode']").val();
        var productId = $("[name='productId']").val();
        var productCode = $("[name='productCode']").val();
        var containerId = $("[name='containerId']").val();
        var containerCode = $("[name='containerCode']").val();
        var wasteSource = $("[name='wasteSource']").val();
        var wasteCommonname = $("[name='wasteCommonname']").val();
        var wasteHazardous = $("[name='wasteHazardous']").val();
        var typeName = $("[name='typeName']").val();
        $.ajax({
            type:"post",
            url:"${pageContext.request.contextPath}/instore/doinstore",
            data:{
                wasteId:wasteId,
                wasteCode:wasteCode,
                productId:productId,
                productCode:productCode,
                containerId:containerId,
                containerCode:containerCode,
                wasteSource:wasteSource,
                wasteCommonname:wasteCommonname,
                wasteHazardous:wasteHazardous,
                typeName:typeName
            },
            // dataType:"json",
            success:function (res){
                alert(res.msg)
            }
        })
    })
</script>

